package com.czxy.controller;

import com.czxy.pojo.Spec;
import com.czxy.service.SpecService;
import com.czxy.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 张青卯
 */
@RestController
@RequestMapping
public class SpecController {

    private final SpecService specService;

    @Autowired
    public SpecController(SpecService specService) {
        this.specService = specService;
    }

    @GetMapping("/specifications/{catid}")
    public ResponseEntity<Object> specifications(@PathVariable("catid") Integer catid){
        List<Spec> specList = specService.specifications(catid);
        BaseResult result = new BaseResult(0, "成功", specList);
        return ResponseEntity.ok(result);
    }
}
